<!DOCTYPE html>
<html lang="en">
<head>
    <title>{dede:global.cfg_webname/}</title>
    {dede:include filename="common_head.htm"/}
</head>
<body>
    <div class="main-wrap index-wrap about-wrap show-room-wrap">
        {dede:include filename="header.htm"/}
        {dede:include filename="banner_inner.htm"/}
        <div class="content">
            <div class="content-nav-wrap cur-nav-wrap fixed-nav-wrap tran03 z9999 over mb-0 bg-fff w100 pos-f op-0">
                <div class="container content-nav-con over-xs">
                    <ul class="list-wrap content-nav-list-wrap rcs">
                        {dede:channel type='son'}
                        <li class="list-item content-nav-item [field:id runphp='yes']if(@me== 19)@me='cur';[/field:id]">
                            <a href="javascript:onPressNavItem('anchor-[field:id/]');" class="list-item-a content-nav-item-a">[field:typename/]</a>
                        </li>
                        {/dede:channel}
                    </ul>
                </div>
            </div>
            <div class="content-nav-wrap over mb-0 bg-fff w100 z9999">
                <div class="container content-nav-con over-xs">
                    <ul class="list-wrap content-nav-list-wrap rcs">
                        {dede:channel type='son'}
                        <li class="list-item content-nav-item [field:id runphp='yes']if(@me== 19)@me='cur';[/field:id]">
                            <a href="javascript:onPressNavItem('anchor-[field:id/]');" class="list-item-a content-nav-item-a">[field:typename/]</a>
                        </li>
                        {/dede:channel}
                    </ul>
                </div>
            </div>
            <div class="content-con-wrap show-room-content news-content">
                {dede:channelartlist typeid='19,19'}
                <div id='anchor-19' class="content-item-wrap show-room-content-item wow slideInUp1">
                    <div class="content-item-title-wrap container over">
                        <div class="over wow slideInUp title flex rcs">{dede:field name='typename' /}</div>
                    </div>
                    <ul class="content-item-con-wrap list-wrap news-list-wrap">
                        <li class="list-item news-list-item flex rsb wow slideInUp1 none"></li>
                        {dede:arclist channelid='1' addfields='body' orderby='id' orderway='asc'}
                        <li class="list-item news-list-item flex rsb wow slideInUp1">
                            <div class="pic-wrap news-img-wrap left-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                            <div class="news-info-wrap flex flex-1">
                                <div class="context-wrap">
                                    <div class="info-content over">
                                        <div class="wow slideInUp pic-wrap news-img-wrap mobile-news-img-wrap flex-1 none swiper-container">
                                            <div class="swiper-wrapper">
                                                <img src="[field:picname/]" alt="" class="pic-img news-img swiper-slide" />
                                            </div>
                                        </div>
                                        <div class="wow slideInUp title-wrap">
                                            <div class="news-title text-line line-2">[field:fulltitle/]</div>
                                            <div class="title-line"></div>
                                        </div>
                                        <div class="wow slideInUp news-detail text-j">[field:body/]</div>
                                    </div>
                                </div>
                            </div>
                            <div class="pic-wrap news-img-wrap right-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                        </li>
                        {/dede:arclist}
                    </ul>
                </div>
                {/dede:channelartlist}
                {dede:channelartlist typeid='20,20'}
                <div id='anchor-20' class="content-item-wrap show-room-content-item wow slideInUp1">
                    <div class="content-item-title-wrap container over">
                        <div class="over wow slideInUp title flex rcs">{dede:field name='typename' /}</div>
                    </div>
                    <ul class="content-item-con-wrap list-wrap news-list-wrap">
                        {dede:arclist channelid='1' addfields='body' orderby='id' orderway='asc'}
                        <li class="list-item news-list-item flex rsb wow slideInUp1">
                            <div class="pic-wrap news-img-wrap left-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                            <div class="news-info-wrap flex flex-1">
                                <div class="context-wrap">
                                    <div class="info-content over">
                                        <div class="wow slideInUp pic-wrap news-img-wrap mobile-news-img-wrap flex-1 none swiper-container">
                                            <div class="swiper-wrapper">
                                                <img src="[field:picname/]" alt="" class="pic-img news-img swiper-slide" />
                                            </div>
                                        </div>
                                        <div class="wow slideInUp title-wrap">
                                            <div class="news-title text-line line-2">[field:fulltitle/]</div>
                                            <div class="title-line"></div>
                                        </div>
                                        <div class="wow slideInUp news-detail text-j">[field:body/]</div>
                                    </div>
                                </div>
                            </div>
                            <div class="pic-wrap news-img-wrap right-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                        </li>
                        {/dede:arclist}
                    </ul>
                </div>
                {/dede:channelartlist}
                {dede:channelartlist typeid='21,21'}
                <div id='anchor-21' class="content-item-wrap show-room-content-item wow slideInUp1">
                    <div class="content-item-title-wrap container over">
                        <div class="over wow slideInUp title flex rcs">{dede:field name='typename' /}</div>
                    </div>
                    <ul class="content-item-con-wrap list-wrap news-list-wrap">
                        <li class="list-item news-list-item flex rsb wow slideInUp1 none"></li>
                        {dede:arclist channelid='1' addfields='body' orderby='id' orderway='asc'}
                        <li class="list-item news-list-item flex rsb wow slideInUp1">
                            <div class="pic-wrap news-img-wrap left-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                            <div class="news-info-wrap flex flex-1">
                                <div class="context-wrap">
                                    <div class="info-content over">
                                        <div class="wow slideInUp pic-wrap news-img-wrap mobile-news-img-wrap flex-1 none swiper-container">
                                            <div class="swiper-wrapper">
                                                <img src="[field:picname/]" alt="" class="pic-img news-img swiper-slide" />
                                            </div>
                                        </div>
                                        <div class="wow slideInUp title-wrap">
                                            <div class="news-title text-line line-2">[field:fulltitle/]</div>
                                            <div class="title-line"></div>
                                        </div>
                                        <div class="wow slideInUp news-detail text-j">[field:body/]</div>
                                    </div>
                                </div>
                            </div>
                            <div class="pic-wrap news-img-wrap right-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                        </li>
                        {/dede:arclist}
                    </ul>
                </div>
                {/dede:channelartlist}
                {dede:channelartlist typeid='22,22'}
                <div id='anchor-22' class="content-item-wrap show-room-content-item wow slideInUp1">
                    <div class="content-item-title-wrap container over">
                        <div class="over wow slideInUp title flex rcs">{dede:field name='typename' /}</div>
                    </div>
                    <ul class="content-item-con-wrap list-wrap news-list-wrap">
                        {dede:arclist channelid='1' addfields='body' orderby='id' orderway='asc'}
                        <li class="list-item news-list-item flex rsb wow slideInUp1">
                            <div class="pic-wrap news-img-wrap left-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                            <div class="news-info-wrap flex flex-1">
                                <div class="context-wrap">
                                    <div class="info-content over">
                                        <div class="wow slideInUp pic-wrap news-img-wrap mobile-news-img-wrap flex-1 none swiper-container">
                                            <div class="swiper-wrapper">
                                                <img src="[field:picname/]" alt="" class="pic-img news-img swiper-slide" />
                                            </div>
                                        </div>
                                        <div class="wow slideInUp title-wrap">
                                            <div class="news-title text-line line-2">[field:fulltitle/]</div>
                                            <div class="title-line"></div>
                                        </div>
                                        <div class="wow slideInUp news-detail text-j">[field:body/]</div>
                                    </div>
                                </div>
                            </div>
                            <div class="pic-wrap news-img-wrap right-img-wrap flex-1">
                                <img src="[field:picname/]" alt="" class="pic-img news-img" />
                            </div>
                        </li>
                        {/dede:arclist}
                    </ul>
                </div>
                {/dede:channelartlist}
            </div>
        </div>
        {dede:include filename="footer.htm"/}
        {dede:include filename="common_script.htm"/}
    </div>

    <script>

        var lock = false;

        var windowWidth = $(window).width();
        if (windowWidth < 641) {
            fixedHeight = 56 + 96;
        } else {
            fixedHeight = 70 + 88;
        }

        var titleWidths = [];
        var timer = null;


        $(function() {

            var anchorId = "anchor-{dede:field.typeid/}";
            if (anchorId !== 'anchor-19') {
                onPressNavItem(anchorId, true);
            }

            var headerWrap = $('.header-wrap'),
                headerHeight = headerWrap.height(),
                bannerWrap = $('.banner-wrap.inner-banner-wrap'),
                bannerHeight = bannerWrap.height(),
                navWrap = $('.content-nav-wrap'),
                navHeight = navWrap.height(),
                navListWrap = $('.content-nav-list-wrap');

                $('.cur-nav-wrap').find('.content-nav-item').each(function() {
                    console.log('this---->', this);
                    titleWidths.push($(this).width());
                    console.log('titleWidths---->', titleWidths);
                })

            $(window).on('scroll', function() {
                var { scrollY } = window;
                var currentTop = bannerHeight - $(window).scrollTop() - 70;

                if (currentTop <= 0) {
                    navWrap.addClass('cur');
                } else {
                    navWrap.removeClass('cur');
                }

                var titles = [
                    $('#anchor-19'),
                    $('#anchor-20'),
                    $('#anchor-21'),
                    $('#anchor-22')
                ];

                titles.reduce((initial, title, index) => {
                    if ( !$("#anchor-19") && !$("#anchor-20") && !$("#anchor-21") && !$("#anchor-22") ) {
                        return;
                    }
                    if (initial) return initial;


                    titleHeight = title.height();
                    titleOffsetTop = title.offset().top;

                    if (titles[index +1]) {
                        titleHeightNext = titles[index+1].height();
                        titleOffsetTopNext = titles[index+1].offset().top;
                    } else {
                        titleHeightNext = titleHeight;
                        titleOffsetTopNext = titleOffsetTop + 60;
                    }


                    if (Math.ceil(scrollY + headerHeight + navHeight) <= Math.floor(titleOffsetTopNext - 80)) {
                        if (!lock) {
                            initial = true;
                            var _this = navListWrap.find('.content-nav-item').eq(index);
                            _this.addClass('cur').siblings().removeClass('cur');

                            if (timer) clearTimeout(timer);
                            timer = setTimeout(function() {
                                scrollNavLeftCur(index);
                            }, 200);
                        }
                    }
                    return initial;
                }, false);
                lock = false;
            });

        });


        function scrollNavLeftCur(index) {
            var totalWidth = 0,
                navWrap = $('.content-nav-wrap.cur-nav-wrap .content-nav-con');

            titleWidths.forEach(function(item, _index) {
                if (_index < index - 1) {
                    totalWidth += item;
                }
            });
            totalWidth = totalWidth + (windowWidth - titleWidths[index]) / 2;

            console.log('titleWidths, totalWidth---->', titleWidths, totalWidth);

            if (index == 0) {
                totalWidth = 0

            }
            navWrap.animate({scrollLeft: totalWidth}, 200, "easeInOutCubic");
        }



        function onPressNavItem(anchorId, isLoading = false) {

            var headerWrap = $('.header-wrap'),
                headerHeight = headerWrap.height(),
                bannerWrap = $('.banner-wrap.inner-banner-wrap'),
                bannerHeight = bannerWrap.height(),
                navWrap = $('.content-nav-wrap'),
                navHeight = navWrap.height(),
                navListWrap = $('.content-nav-list-wrap');

            var element = $('#' + anchorId);
            var top = element.offset().top - fixedHeight;

            $("html,body").animate({scrollTop: top}, 500, "easeInOutCubic");
            lock = true;
        }

    </script>
</body>
</html>